<?php
$isadmin=1;
include "../../comm/tuaninc.php";
include('../check.php');
include "../../comm/class_db.php";
include_once '../include/page.class.php';
$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=20;
$page2=($page-1)*$pagesize;
$keyword=$_GET['keyword'];
$mall_id=$_GET['mall_id'];

if($mall_id>0){
    $and=' and mall_id='.$mall_id;
}
else{
    $and='';
}

$sql="select id,name from ".$duoduo->BIAOTOU."mall where catid = ".TUANCID." and api_url is not null and api_url<>'' order by sort desc";
$query=$duoduo->query($sql);
while($row=$duoduo->fetch_array($query)){
    $mall_arr[$row['id']]=$row['name'];
}

$sql="select id,catename from ".$duoduo->BIAOTOU."catelist";
$query=$duoduo->query($sql);
while($row=$duoduo->fetch_array($query)){
    $cate_arr[$row['id']]=$row['catename'];
}

$total=$duoduo->sql_count("tuan_goods","id","`title` like '%".$keyword."%'".$and);
$sql="select id,local,mall_id,catname,city,title,image,startTime,endTime,value,price,rebate,bought,sort,top from ".$duoduo->BIAOTOU."tuan_goods where `title` like '%".$keyword."%' ".$and."  order by top desc,sort desc, endTime desc limit $page2,$pagesize";
$rs = $duoduo->query($sql);

$top_arr=array(0=>'否',1=>'<b style=" color:red">是</b>');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<script src="../../js/jquery.js"></script>
<script>
$("document").ready(function(){
    $("#all").click(function(){   
       if(this.checked){   
           $("input[type='checkbox']").each(function(){this.checked=true;});
           $("#btn1").attr("value","反选");   
       }else{   
           $("input[type='checkbox']").each(function(){this.checked=false;});   
           $("#btn1").attr("value","全选"); 
       }   
    });  
});

</script>
<style type="text/css">
<!--
.STYLE1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
.STYLE2 {
	color: #555555;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
-->
</style>
</head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" width="100%" height="207" style="border:1px  solid #DCEAF7;">
            <tr>
              <td width="208" height="30" align="left" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="../images/arrow.gif" width="16" height="22" align="absmiddle" /> 内容管理 [ <a href="goods.php" class="link3">添加团购</a> ] </strong> [<a href="del.php?act=timedel">删除过期商品</a>]</td>
              <form id="form1" name="form1" method="get" action="">
              <td width="429" align="left" bgcolor="E9F2FB" class="bigtext">
              商品名：<input type="text" class="button3" name="keyword" /> &nbsp;&nbsp;团购网：<?=select($mall_arr,"mall_id",$kword,500)?>
                <input type="submit" name="Submit" value="查找" /> <a href="goodslist.php">全部</a>
                </td></form>
              <td width="130" height="30" align="right" bgcolor="E9F2FB" class="bigtext">共有 <b><?php echo $total;?></b> 条记录&nbsp;&nbsp;</td>
            </tr>
            <tr>
              <td colspan="3" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><table width="100%" border=1 cellpadding=0 cellspacing=0 style="border-collapse: collapse" bordercolor="#dddddd">
                    <form action="del.php">
                    <tr>
                      <td width="3%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong><input id="all" type='checkbox' /></strong></td>
                      <td width="" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>商品名</strong></td>
                      <td width="5%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>城市</strong></td>
                      <td width="7%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>网站</strong></td>
                      <td width="8%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>图片</strong></td>
                      <td width="8%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>开始时间</strong></td>
                      <td width="8%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>结束时间</strong></td>
                      <td width="5%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>原价</strong></td>
                      <td width="5%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>现价</strong></td>                     
                      <td width="5%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>折扣</strong></td>
                      <td width="6%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>购买人数</strong></td>
                      <td width="4%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>排序</strong></td>
                      <td width="4%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>置顶</strong></td>
                      <td width="8%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>操作</strong></td>
                    </tr>
                    
                    <?php
					while ($row = mysql_fetch_array($rs))
					{
						echo "<tr>";
						echo "<td height=30 align=\"center\" class=bigtext><input type='checkbox' name='ids[]' value='".$row["id"]."' id='content_".$row["id"]."' /></td>";
                      	echo "<td height=30 align=\"center\" class=bigtext><a href='".$row["local"]."' target='_blank'>".$duoduo->utf_substr($row["title"],40)."</a></td>";
						echo "<td height=30 align=\"center\" class=bigtext>".$row["city"]."</td>";
						echo "<td height=30 align=\"center\" class=bigtext>".$mall_arr[$row["mall_id"]]."</td>";
                      	echo "<td height=30 align=\"center\" class=bigtext><img height='30px' width='60px' src=".$row["image"]." /></td>";
						echo "<td height=30 align=\"center\" class=bigtext>".date('Y-m-d',$row["startTime"])."</td>";
						echo "<td height=30 align=\"center\" class=bigtext>".date('Y-m-d',$row["endTime"])."</td>";
						echo "<td height=30 align=\"center\" class=bigtext>".$row["value"]."</td>";
						echo "<td align=\"center\" class=bigtext id=ss>".$row["price"]."</td>";	
						echo "<td align=\"center\" class=bigtext id=ss>".$row["rebate"]."</td>";
						echo "<td align=\"center\" class=bigtext id=ss>".$row["bought"]."</td>";
						echo "<td align=\"center\" class=bigtext id=ss>".$row["sort"]."</td>";	
						echo "<td align=\"center\" class=bigtext id=ss>".$top_arr[$row["top"]]."</td>";	
						echo "<td align=\"center\" class=bigtext><a href=goods.php?id=".$row["id"]." class=link4>修改</a> <a href=goodsdel.php?id=".$row["id"]." class=link4 onclick='return confirm(\"确定要删除?\")' >删除</a></td>";	
						echo "</tr>";
					}
					?>
                    <tr>
                      <td height="43" colspan="13" align="center"><div id="pages">
                          <div class="yahoo2" id="pages" style=" position:relative; height:30px">
                      <div style="position:absolute; left:px; top:5px"><input type="submit" value="删除" onclick='return confirm("确定要删除?")'/></div>
						  <?php  pageft($total,$pagesize,1,1,0,10,"goodslist.php?keyword=".urlencode($keyword).'&mall_id='.$_GET['mall_id']);echo $pagenav;?></div>
                      </div></td>
                    </tr>
                    </form>
                  </table></td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
</body>
</html>